package game.ui.controls
{
	import engine.asset.*;
	import engine.core.*;
	import engine.sound.*;
	import flash.events.*;
	import flash.geom.*;
	import flash.text.*;
	import game.ui.core.*;
	
	public class RxButtonBase extends RxUIElement implements RxIDataRenderer
	{
		private var m_upColor:uint = 14540253;
		private var m_downColor:uint = 12303291;
		private var m_selectedColor:uint = 11184810;
		private var m_borderColor:uint = 0;
		private var m_borderThickness:int = 1;
		protected var m_labelField:RxTextLabel;
		protected var m_iconDisplay:RxBitmap;
		protected var m_tooltip:RxTooltip;
		protected var m_background:RxBitmap;
		protected var m_state:String;
		protected var m_mode:String = "normal";
		protected var m_enabled:Boolean = true;
		protected var m_highlighted:Boolean;
		protected var m_label:String;
		protected var m_callback:Function;
		protected var m_callbackParam:Object;
		protected var m_labelPlacement:String;
		protected var m_drawBackground:Boolean = true;
		protected var m_tooltipData:Object = null;
		protected var m_tooltipPlacement:String = null;
		protected var m_tooltipDelay:Number = 0;
		protected var m_preventMousePropagation:Boolean = false;
		protected var m_rollOverCursor:String;
		protected var m_cursorPriority:int = 1;
		protected var m_toggled:Boolean = false;
		protected var m_selected:Boolean = false;
		protected var m_rollOverSound:String = "uiButtonRollOver";
		protected var m_clickSound:String = "uiButtonClick";
		protected var m_altClickSound:String = "uiButtonClick";
		protected var m_data:Object;
		protected var m_dataIndex:int = -1;
		protected var m_telemetryId:String;
		protected var m_sessionGenerator:Function;
		public static const BUTTON_STATE_UP:String = "up";
		public static const BUTTON_STATE_DOWN:String = "down";
		public static const BUTTON_STATE_SELECTED:String = "selected";
		public static const BUTTON_STATE_OVER:String = "over";
		public static const BUTTON_STATE_DISABLED:String = "disabled";
		
		public function RxButtonBase(param1:String = "", param2:String = null, param3:TextFormat = null, param4:String = null)
		{
			this.m_rollOverCursor = RxUICursor.INTERACTIVE;
			if (param2 != null)
			{
				this.m_mode = param2;
			}
			this.m_state = BUTTON_STATE_UP;
			this.m_labelPlacement = param4 ? (param4) : (RxUIPositionConstants.BOTTOM);
			this.SetLabel(param1);
			this.SetTextFormat(param3);
			/*
			addEventListener(MouseEvent.CLICK, this.OnClick);
			addEventListener(MouseEvent.MOUSE_DOWN, this.OnMouseDown);
			addEventListener(MouseEvent.ROLL_OVER, this.OnRollOver);
			addEventListener(MouseEvent.ROLL_OUT, this.OnRollOut);*/
			InvalidateSize();
		}
		
		public function SetLabel(param1:String) : void
		{
			this.label = param1;
		}
		
		public function set label(param1:String) : void
		{
			if (param1 == this.m_label)
			{
				return;
			}
			if (param1 == null)
			{
				param1 = "";
			}
			this.m_label = param1;
			if (!this.m_labelField)
			{
				this.CreateLabelDisplay();
			}
			this.m_labelField.text = param1;
			if (this.m_label == "" && this.m_labelField.stage)
			{
				removeChild(this.m_labelField);
			}
			InvalidateSize();
		}
		
		protected function CreateLabelDisplay(param1:TextFormat = null) : void
		{
			this.m_labelField = RxTextLabel.CreateWithStyle(RxFontStyleConstants.BODY_LARGE, 0, TextFormatAlign.CENTER);
			this.m_labelField.mouseEnabled = false;
			this.m_labelField.mouseChildren = false;
			addChild(this.m_labelField);
			if (param1)
			{
				this.SetTextFormat(param1);
			}
			/*
			if (this.label)
			{
				this.m_labelField.text = this.label;
			}*/
		}
		
		public function SetTextFormat(param1:TextFormat) : void
		{
			if (param1 == null)
			{
				return;
			}
			if (!this.m_labelField)
			{
				this.CreateLabelDisplay(param1);
			}
			else
			{
				this.m_labelField.SetTextFormat(param1);
			}
			InvalidateSize();
		}
		
		public function GetData() : Object
		{
			return this.m_data;
		}
		
		public function SetDataIndex(param1:int) : void
		{
			this.m_dataIndex = param1;
		}
		
		public function GetDataIndex() : int
		{
			return this.m_dataIndex;
		}
		
		public function IsSelected() : Boolean
		{
			return false;
		}
		
		public function SetSelected(param1:Boolean) : void
		{

		}
		
		public function SetData(param1:Object) : void
		{
			/*
			var _loc_2:int = 0;
			var _loc_3:int = 0;
			var _loc_4:String = null;
			this.m_data = param1;
			if (this.m_data == null)
			{
				this.text = "";
				if (this.m_icon)
				{
					this.m_icon.url = "";
				}
			}
			else if (this.m_data is String)
			{
				this.text = this.m_data as String;
			}
			else
			{
				if (this.m_data.hasOwnProperty("htmlText"))
				{
					this.htmlText = this.m_data.htmlText;
				}
				else if (this.m_data.hasOwnProperty("text"))
				{
					this.text = this.m_data.text;
				}
				if (this.m_data.hasOwnProperty("color"))
				{
					this.textColor = this.m_data.color;
				}
				_loc_2 = 0;
				_loc_3 = 0;
				_loc_4 = null;
				if (this.m_data.hasOwnProperty("iconUrl"))
				{
					_loc_4 = this.m_data.iconUrl;
				}
				if (this.m_data.hasOwnProperty("iconWidth"))
				{
					_loc_2 = this.m_data.iconWidth;
				}
				if (this.m_data.hasOwnProperty("iconHeight"))
				{
					_loc_3 = this.m_data.iconHeight;
				}
				this.SetIconUrl(_loc_4, _loc_2, _loc_3);
			}
			InvalidateSize();
			this.UpdateDisplayState();*/
		}
		
		public function SetIconUrl(param1:String, param2:int = -1) : void
		{
			/*
			if (!this.m_iconDisplay)
			{
				this.CreateIconDisplay();
			}
			if (param2 == -1)
			{
				param2 = RxAsset.SOURCE_LOCAL;
			}
			this.m_iconDisplay.addEventListener(Event.COMPLETE, this.OnIconLoaded);
			this.m_iconDisplay.SetUrl(param1, param2);
			*/
		}
		
		public function SetCallback(param1:Function, param2:Object = null) : void
		{
			this.m_callback = param1;
			this.m_callbackParam = param2;
		}
	}
}